package com.example.lanqiaodemo1.java16;
interface Shape {
    public abstract double getArea();
    public abstract double getPerimeter();
}
class Circle implements Shape{
    double r;
    public double getR() {
        return r;
    }
    public void setR(double r) {
        this.r = r;
    }
    public Circle(double r) {
        this.r = r;
    }
    public Circle(){}
    public double getArea() {
       return r*r*Math.PI;
    }
    public double getPerimeter() {
        return 2*r*Math.PI;
    }
}
class Rectangle implements Shape{

   double x,y;

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public Rectangle(double x, double y) {
        this.x = x;
        this.y = y;
    }

    public double getArea() {
        return x*y;
    }

    public double getPerimeter() {
        return 2*(x+y);
    }
}

public class Test {
    public static void main(String[] args) {
        Circle c = new Circle(2);
        Rectangle r=new Rectangle(3,4);
        System.out.println("圆的面积是："+c.getArea());
        System.out.println("圆的周长是："+c.getPerimeter());
        System.out.println("长方形的面积是："+r.getArea());
        System.out.println("长方形的周长是："+r.getPerimeter());
    }

}
